
<template>
  <div class="listCardRoot">
    <div class="itemCard" v-for="v in listCardData " :key="v.id">
      <img class="image" :src="`${v.picUrl||v.coverImgUrl}?param=400y400`" alt="" @click="handleItemClick(v.id)">
      <p class="title">{{v.name}}</p>
    </div>
  </div>
</template>

<script>
import { onMounted } from 'vue'
export default {
  name: 'listCard',
  props: {
    listCardData: {
      type: Array,
      default() {
        return []
      }
    }
  },
  setup(p, { emit }) {
    const handleItemClick = id => {
      console.log('itemCardClick')
      emit('itemCardClick', id)
    }
    onMounted(() => {
      console.log(p.listCardData)
    })
    return {
      handleItemClick
    }
  }
}
</script>

<style scoped>
.listCardRoot {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
}
.itemCard {
  margin: 0 2% 20px 0;
  width: 18%;
}
.image {
  min-height: 100px;
  width: 100%;
  border-radius: 5px;
  cursor: pointer;
}
.title {
  font-size: 12px;
  padding: 0 2px;
  margin-top: 8px;
}
</style>